var e = require("../../@babel/runtime/helpers/interopRequireDefault"), t = e(require("../../@babel/runtime/regenerator")), n = require("../../@babel/runtime/helpers/asyncToGenerator"), r = require("../../config"), i = e(require("../../http/system")), a = require("../../utils/tool"), o = e(require("../../http/directBuyApi")), s = new i.default(), u = new o.default(), c = getApp();

Component({
    properties: {
        loginInfo: {
            type: Object
        },
        otherInfo: {
            type: Object
        }
    },
    data: {
        vipIconList: r.vipIconList,
        defaultAvatar: "http://newimg.ap1983.com/prod/20210830/aed7064d195f40a7b0ab464891f3a94a.png"
    },
    methods: {
        toLogin: function() {
            wx.navigateTo({
                url: "/pages/login/login"
            });
        },
        toPage: function(e) {
            var t = e.currentTarget.dataset.url;
            c.global.loginThenRedirectTo(t);
        },
        toPoint: function(e) {
            if (c.global.isLogin()) this.overListen(); else {
                var t = e.currentTarget.dataset.url;
                c.global.loginThenRedirectTo(t);
            }
        },
        overListen: function() {
            var e = this;
            return n(t.default.mark(function n() {
                var r, i, a, o, s, u, c;
                return t.default.wrap(function(t) {
                    for (;;) switch (t.prev = t.next) {
                      case 0:
                        return t.next = 2, e.getNowTime();

                      case 2:
                        r = t.sent, wx.getStorageSync("tappingTime") ? (i = new Date(wx.getStorageSync("tappingTime")).getTime(), 
                        a = new Date(r).getFullYear(), o = new Date(r).getMonth(), s = new Date(a, o, 1).getTime(), 
                        u = new Date(a, o + 1, 1).getTime(), c = new Date(a, o, 18, 10, 0, 0).getTime(), 
                        new Date(r).getTime() < c && i > s && i < c || new Date(r).getTime() > c && i > c && i < u ? wx.navigateTo({
                            url: "/pages/point-list/point-list"
                        }) : e.subscribe()) : e.subscribe();

                      case 4:
                      case "end":
                        return t.stop();
                    }
                }, n);
            }))();
        },
        subscribe: function() {
            var e = this;
            return n(t.default.mark(function n() {
                var r;
                return t.default.wrap(function(t) {
                    for (;;) switch (t.prev = t.next) {
                      case 0:
                        return t.next = 2, e.getNowTime();

                      case 2:
                        r = t.sent, wx.requestSubscribeMessage({
                            tmplIds: [ "MB3dRY6WLJhC1kSxHEjspgF3fHrRuB5UXt2_x9gfVpw" ],
                            success: function(e) {
                                wx.setStorageSync("tappingTime", r), "accept" == e.MB3dRY6WLJhC1kSxHEjspgF3fHrRuB5UXt2_x9gfVpw ? (wx.showLoading({
                                    title: "加载中",
                                    mask: !0
                                }), u.listen(2).then(function(e) {
                                    (0, a.toastToPage)("订阅成功"), wx.navigateTo({
                                        url: "/pages/point-list/point-list"
                                    });
                                }).catch(function(e) {
                                    wx.hideLoading();
                                })) : (wx.hideLoading(), (0, a.toastToPage)("取消订阅"), wx.navigateTo({
                                    url: "/pages/point-list/point-list"
                                }));
                            },
                            fail: function(e) {
                                wx.navigateTo({
                                    url: "/pages/point-list/point-list"
                                });
                            },
                            complete: function(e) {}
                        });

                      case 4:
                      case "end":
                        return t.stop();
                    }
                }, n);
            }))();
        },
        getNowTime: function() {
            return n(t.default.mark(function e() {
                var n;
                return t.default.wrap(function(e) {
                    for (;;) switch (e.prev = e.next) {
                      case 0:
                        return e.next = 2, s.getServerTime();

                      case 2:
                        return n = e.sent, e.abrupt("return", (0, a.formatIosTime)(n.data.systemDate));

                      case 4:
                      case "end":
                        return e.stop();
                    }
                }, e);
            }))();
        }
    }
});